import { _decorator, Component, Node, log, Button, EditBox, EventHandler } from 'cc';
import { ExWidget } from '../../component/ExWidget';
import { BaseView } from '../BaseView';
import Notification from '../../lib/mvp/Notification';
import { winMgr } from '../../tool/WinMgr';

const { ccclass, executionOrder, executeInEditMode, property } = _decorator;

@ccclass('LoginView')
// @executionOrder(100)
// @executeInEditMode(true)
export class LoginView extends BaseView {

    //事件名称
    static LOGINVIEW_OK = "LOGINVIEW_OK";
    static LOGINVIEW_Cancel = "LOGINVIEW_Cancel";
    static LOGINVIEW_CLOSE = "LOGINVIEW_Close";

    @property(Button)
    private buttonOK: Button = null;
    @property(EditBox)
    private editboxName: EditBox = null;
    @property(EditBox)
    private editboxPassword: EditBox = null;


    onLoad(): void {
        super.onLoad();

        this.init("LoginView");

    }

    start() {

    }

    public handleNotification(notification: Notification): void {
        if (notification.getName() == LoginView.LOGINVIEW_CLOSE) {
            this.close();
        }
        else {

        }
    }

    public listNotificationInterests(): string[] {
        let list: Array<string> = [
            LoginView.LOGINVIEW_OK,
            LoginView.LOGINVIEW_Cancel,
            LoginView.LOGINVIEW_CLOSE,
        ];
        return list;
    }

    public OnClick_OK(event: Event, customEventData: string): void {

        let obj = { name: this.editboxName.string, password: this.editboxPassword.string };
        this.sendNotification(LoginView.LOGINVIEW_OK, obj);

    }
}

